<template>
	<view class="content" v-if="show==1">
		<view class="header">
		    <view class="header_1" v-if="uid>0">
		      <view class="avatar" @click="info">
		        <image :src="user.avatar" mode='aspectFill'></image>
		      </view>
		      <view class="nickname" @click="info">
		        <view class="nick">{{user.nickname}}</view>
		        <view class="level">{{user.mobile}}</view>
		      </view>
		    </view>
			<view class="header_1" v-if="uid==0">
			  <view class="avatar" @click="info">
			    <image src="../../static/images/avatar.png" mode='aspectFill'></image>
			  </view>
			  <view class="nickname" @click="info">
			    <view class="nick2">欢迎您，请登录</view>
				<view class="nick3">登录</view>
			  </view>
			</view>
		</view>
		<!--<view class="fenge"></view>
		<view class="order">
		    <view class="order_1">
		      <view class="order_1_1">我的订单</view>
		      <view class="order_1_2" @click="ding" data-id="0">
		        <image src="../../static/right_1.png" mode='widthFix'></image>
		        <text>查看全部</text>
		      </view>
		    </view>
		
		    <view class="order_2">
		      <view class="status" @click="ding" data-id="1">
		        <view class="status_1">
		          <image src="../../static/images/icon7.png" mode='widthFix'></image>
		        </view>
		        <view class="status_2">待付款</view>
		        <text class="count" v-if="user.dfk_count>0">{{user.dfk_count}}</text>
		      </view>
		      
		      <view class="status"  @click="ding" data-id="2">
		        <view class="status_1">
		          <image src="../../static/images/icon5.png" mode='widthFix'></image>
		        </view>
		        <view class="status_2">待评价</view>
				<text class="count" v-if="user.dpj_count>0">{{user.dpj_count}}</text>
		      </view>
			  <view class="status"  @click="ding" data-id="3">
			    <view class="status_1">
			      <image src="../../static/images/icon6.png" mode='widthFix'></image>
			    </view>
			    <view class="status_2">已完成</view>
			  </view>
		    </view>
		  </view>-->
		
		  <view class="fenge"></view>
		
		  <view class="order" >
		    <view class="order_1">
		      <view class="order_1_1">我的服务</view>
		      
		    </view>
			<view v-if="zdtype==1" class="dao" @click="url" data-url="/pages/user/money" data-id="1">
				<image src="../../static/images/u_7.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">我的课券<text v-if="user.kequan" style="float: right;font-size: 0.85rem;">㉿{{user.kequan}}</text></view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<!-- <view class="dao" @click="url" data-url="/pages/user/daili" data-id="1">
				<image src="../../static/images/daili.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">代理中心</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view> -->
			<view class="dao" @click="url" data-url="/pages/user/yao" data-id="1">
				<image src="../../static/images/u_1.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">邀请好友<text v-if='site.yhq_money>0'>得{{site.yhq_money}}元红包</text></view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			
			<!--<view class="dao" @click="fx" data-url="/pages/user/yao">
				<image src="../../static/images/u_1.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">邀请好友</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			
			<button class="dao hb6" type="default" open-type="share" plain="true">
				<image src="../../static/images/u_1.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">邀请好友</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</button>-->
			
			<view class="dao" @click="url" data-url="/pages/user/coll" data-id="1">
				<image src="../../static/images/u_5.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">我的收藏</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<view class="dao" @click="url" data-url="/pages/user/yhq" data-id="1">
				<image src="../../static/images/u_4.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">我的优惠券</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			
			<view class="dao" @click="kefu">
				<image src="../../static/images/u_3.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">联系我们</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<!-- #ifdef MP-WEIXIN -->
			<view class="dao" @click="url" data-url="/pages/user/site">
				<image src="../../static/images/u_10.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">设置账号</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
			<!-- #endif-->
			<!--<view class="dao" @click="laoshi">
				<image src="../../static/images/u_2.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">切换到师傅端</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>-->
			<view class="dao" @click="url" data-url="/pages/teacher/center" data-id='1' v-if="user.is_teacher!=1">
				<image src="../../static/images/u_2.png" class="tubiao" mode="aspectFit"></image>
				<view class="dao2">师傅中心</view>
				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
			</view>
		  </view>
		  
		  <view class="fenge" v-if="user.is_teacher==1"></view>
		  		
		  <view class="order" v-if="user.is_teacher==1" >
		    <view class="order_1">
		      <view class="order_1_1">师傅服务</view>
		      
		    </view>
		  			<view class="dao" @click="url" data-url="/pages/teacher/money" data-id='1'>
		  				<image src="../../static/images/u_9.png" class="tubiao" mode="aspectFit"></image>
		  				<view class="dao2">我的钱包</view>
		  				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
		  			</view>
		  			<view class="dao" @click="url" data-url="/pages/teacher/center">
		  				<image src="../../static/images/u_2.png" class="tubiao" mode="aspectFit"></image>
		  				<view class="dao2">师傅中心</view>
		  				<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
		  			</view>
					<view class="dao" @click="url" data-url="/pages/teacher/kecheng">
						<image src="../../static/images/fb.png" class="tubiao" mode="aspectFit"></image>
						<view class="dao2">发布服务</view>
						<image src="../../static/images/right_2.png" class="tubiao2" mode="aspectFit"></image>
					</view>
		  </view>
			<view style="width:100%;height:55px;"></view>
		  <view class="kefu" v-if="is_kf==true"></view>
		  <view class="kefu2" v-if="is_kf==true">
			  <view class="kefu3">
				  <image src="../../static/weixin.png" mode="widthFix"></image>
				  <view class="kefu4">{{site.weixin}}</view>
				  <view class="kefu5" @click="weixin">复制</view>
			  </view>
			  <view class="kefu3">
							  <image src="../../static/qq.png" mode="widthFix"></image>
							  <view class="kefu4">{{site.qq}}</view>
							  <view class="kefu5" @click="qq">复制</view>
			  </view>
			  <view class="kefu3">
							  <image src="../../static/tel.png" mode="widthFix"></image>
							  <view class="kefu4">{{site.tel}}</view>
							  <view class="kefu5" @click="tel">拨打</view>
			  </view>
			  <image @click="kefu" src="../../static/cha.png" mode='widthFix' class="chazi"></image>
		  </view>
		  <daohang count='4'></daohang>
	</view>
</template>

<script>
	var app=getApp();
	import { setClipboardData, getClipboardData } from '@/uni_modules/u-clipboard/js_sdk';
	import daohang from "../../components/daohang.vue"
	export default {
		components: {
			daohang
		},
		data() {
			return {
				show:0,
				is_l:0,
				zdtype:0,
				is_kf:false,
				uid:0,
				site:[],
				user:[]
			}
		},
		onNavigationBarButtonTap(){
			uni.navigateTo({
			    url: '/pages/user/site'
			});
		},
		onShow() {
			// #ifdef MP-WEIXIN
			uni.hideHomeButton();
			// #endif
			const uid = uni.getStorageSync('uid');
			if(app.isBlank(uid)==true){
				//uni.setStorageSync('js_type',1);
				this.uid=0;
				this.getdata2();
				return false;
			}
			/*var t=uni.getStorageSync('js_type');
			if(t==2){
				uni.reLaunch({
				    url: "/pages/teacher/index"
				});
				return false;
			}*/
			var that=this;
			//#ifdef APP-PLUS
			uni.getSystemInfo({
			    success: function (res) {
					if(res.platform=='ios'){
						//that.zdtype=1;
					}
			    }
			});
			//#endif
			this.uid=uid;
			this.getdata();
		},
		methods: {
			getdata(){
				var that=this;
				/*uni.showLoading({
				    title: '数据加载中'
				});*/
				uni.request({
				    url: app.globalData.url+"user/index",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {uid:that.uid},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code==1){
							that.user=res.data.data.user
							that.site=res.data.data.site
							that.show=1;
						}else if(res.data.code==4000){
							uni.removeStorageSync('uid');
							uni.setStorageSync('js_type',1);
							that.uid=0;
							that.user=[];
							that.show=1;
						}else{
							uni.setStorageSync('js_type',1);
							uni.reLaunch({
							    url: '/pages/index/index'
							});
							return false;
						}
				    }
				});
			},
			getdata2(){
				var that=this;
				/*uni.showLoading({
				    title: '数据加载中'
				});*/
				uni.request({
				    url: app.globalData.url+"index/site",
					method:"POST",
					dataType:"json",
					header: {
					    'content-type': 'application/x-www-form-urlencoded'
					},
				    data: {uid:that.uid},
				    success: (res) => {
						uni.hideLoading();
						if(res.data.code!=1){
							uni.reLaunch({
							    url: '/pages/index/index'
							});
							return false;
						}
						that.site=res.data.data.site
						that.show=1;
				    }
				});
			},
			fx(){
				var that=this;
				uni.share({
				    provider: 'weixin',
				    scene: "WXSceneSession",
				    type: 5,
				    imageUrl: that.site.dl_fx_img,
				    title: that.site.dl_fx_title,
				    miniProgram: {
				        id: 'gh_e35b785da324',
				        path: 'pages/index/index?uid='+that.uid,
				        type: 0,
				        webUrl: 'https://www.bjfen.com'
				    },
				    success: ret => {
				        console.log(JSON.stringify(ret));
				    }
				});
			},
			tuichu(){
				uni.removeStorageSync('uid');
				uni.switchTab({
				    url: '/pages/index/index'
				});
			},
			zhuxiao(){
				var that=this;
				uni.showModal({
				    content: '注销账号后，账号里所有的信息和课程将会被删除，不可恢复，确定要注销吗？',
				    success: function (res) {
				        if (res.confirm) {
				            uni.showLoading({
				                title: '注销中'
				            });
				            uni.request({
				                url: app.globalData.url+"user/zhuxiao",
				            	method:"POST",
				            	dataType:"json",
				            	header: {
				            	    'content-type': 'application/x-www-form-urlencoded'
				            	},
				                data: {uid:that.uid},
				                success: (res) => {
				            		uni.hideLoading();
				            		if(res.data.code!=1){
				            			uni.showToast({
				            			    title: res.data.msg,
				            				icon:'none',
				            			    duration: 1500
				            			});
				            			return false;
				            		}
				            		uni.showToast({
				            		    title: res.data.msg,
				            			icon:'success',
				            		    duration: 1000
				            		});
									setTimeout(function(){
										uni.removeStorageSync('uid');
										uni.reLaunch({
										    url: '/pages/index/index'
										});
									},1000)
				                }
				            });
				        }
				    }
				});
			},
			laoshi(){
				const uid = uni.getStorageSync('uid');
				if(app.isBlank(uid)==true){
					uni.navigateTo({
					    url: '/pages/login/login'
					});
					return false;
				}
				uni.setStorageSync('js_type', 2);
				
				uni.reLaunch({
				    url: "/pages/teacher/index"
				});
			},
			ding(e){
				var s=e.currentTarget.dataset.id;
				uni.setStorageSync('status', s);
				
				uni.reLaunch({
				    url: "/pages/order/index"
				});
			},
			url(e){
				var url=e.currentTarget.dataset.url;
				var id=e.currentTarget.dataset.id;
				const uid = uni.getStorageSync('uid');
				if(app.isBlank(uid)==true && id==1){
					uni.navigateTo({
					    url: '/pages/login/login'
					});
					return false;
				}
				uni.navigateTo({
				    url: url
				});
			},
			kefu(){
				this.is_kf=!this.is_kf;
			},
			weixin(){
				setClipboardData(this.site.weixin);
				uni.showToast({
				    title: '复制成功！',
				    duration: 1000
				});
			},
			qq(){
				setClipboardData(this.site.qq);
				uni.showToast({
				    title: '复制成功！',
				    duration: 1000
				});
			},
			tel(){
				uni.makePhoneCall({
				    phoneNumber: this.site.tel
				});
			},
			info(){
				const uid = uni.getStorageSync('uid');
				if(app.isBlank(uid)==true){
					uni.navigateTo({
					    url: '/pages/login/login'
					});
					return false;
				}
				uni.navigateTo({
				    url: '/pages/user/info'
				});
			},
			onShareAppMessage(res) {
				var that=this;
			    return {
			      title: that.site.dl_fx_title,
				  imageUrl:that.site.dl_fx_img,
			      path: '/pages/index/index?uid='+that.uid
			    }
			}
		}
	}
</script>

<style>
	.hb6{width:100%!important;margin: 0px;line-height: unset;border-top:0px!important;border-left:0px!important;border-right:0px!important;border-bottom: 1px rgb(245, 245, 245) solid!important;}
	.dao2 text{color:red;font-size: 0.7rem;margin-left: 5px;}
	.order .dao:last-child{margin-bottom: 10px;}
	.tubiao2{width:20px;height:20px;margin-top: 7.5px;}
	.dao2{width:100%;height:40px;line-height: 40px;flex:1;font-size: 0.9rem;text-align: left;}
	.tubiao{width:20px;height:20px;margin-top: 10px;margin-right: 8px;}
	.dao{width:94%;padding: 3px 3%;display: flex;height:40px;border-bottom:1px rgb(245, 245, 245) solid;}
	.kefu5{width:40px;height:20px;line-height: 20px;border-radius:5px;text-align: center;margin-top: 10px;border:1px #999 solid;color:#999;font-size: 0.8rem;margin-left: 5px;}
	.kefu4{width:100%;height:40px;line-height: 40px;flex: 1;overflow: hidden;}
	.kefu3 image{width:25px;margin-top: 7.5px;margin-right: 10px;}
	.kefu3{width:94%;padding: 0px 3%;height:40px;display: flex;margin-top: 10px;}
	.chazi{width:40px;height:40px;position: absolute;bottom: -50px;z-index: 9999;left: 50%;margin-left: -20px;}
	.kefu2{width:250px;height:160px;background-color: #fff;position: fixed;top:50%;margin-top: -80px;left: 50%;margin-left: -125px;border-radius: 5px;z-index: 9999;}
	.kefu{width:100%;height:100vh;position: fixed;top:0px;z-index: 9999;background-color: #000000;opacity: 0.7;}
	.user5-3{width:100%;height:20px;line-height: 20px;text-align: center;}
	.user5-2{width:100%;height:30px;line-height: 30px;text-align: center;overflow: hidden;font-size: 0.95rem;}
	.user5-1{width:100%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;}
	.user3-3{width:100%;height:20px;line-height: 20px;text-align: center;}
	.user3-2{width:100%;height:30px;line-height: 30px;text-align: center;overflow: hidden;font-size: 0.95rem;}
	.user3-1{width:100%;height:20px;line-height: 20px;text-align: center;font-size: 0.8rem;}
	.user4-1{width:1px;height:70px;background-color: rgb(245, 245, 245);margin: 0 auto;}
	.user5{width:49.5%;height:70px;float: left;}
	.user4{width:1%;height:70px;float: left;text-align: center;}
	.user3{width:49.5%;height:70px;float: left;}
	.user2{width:96%;padding: 10px 2%;overflow: hidden;}
	
	.header{width:100%;height:100px;position: relative;background-color: #1196db;}
	.header_1{width:100%;height:100px;overflow: hidden;}
	.avatar{width:25%;float: left;text-align: center;height:100px;}
	.avatar image{width:70px;margin-top: 15px;border-radius: 50%;height:70px;}
	.nickname{width:70%;float: left;height:100px;overflow: hidden;}
	.nick{width:100%;height:35px;line-height: 35px;margin-top: 15px;font-size: 1.1rem;color:#fff;overflow: hidden;}
	.nick2{width:70%;height:100px;line-height: 100px;font-size: 1.1rem;color:#fff;overflow: hidden;float: left;}
	.nick3{width:25%;height:33px;border:1px #fff solid;border-radius: 5px;text-align: center;line-height: 33px;color:#fff;float: right;margin-top: 32.5px;}
	.level{width:100px;height:20px;line-height: 20px;border:1px #fff solid;text-align: center;color:#fff;border-radius: 20px;font-size: 0.7rem;margin-top: 5px;}
	.site{width:15%;float: left;height:100px;text-align: center;}
	.site image{width:25px;margin-top: 15px;}
	.bai{width:100%;height:50px;background-color: #fff;opacity: 0.15;position: absolute;bottom: 0px;}
	.yue{width:100%;height:50px;position: absolute;bottom: 0px;overflow: hidden;}
	.money{width:33.33%;float: left;}
	.money_1{width:100%;text-align: center;height:25px;line-height: 30px;font-size: 1.1rem;color:#fff;margin-top: 1px;}
	.money_2{width:100%;text-align: center;height:20px;line-height: 20px;color:#fff;}
	
	.zhong{width:100%;padding: 15px 0px;overflow: hidden;}
	.zhong_1{width:49%;float: left;overflow: hidden;}
	.level_img{width:40%;float: left;text-align: right;}
	.level_img image{width:40px;margin-right: 10px;}
	.level_title{width:60%;float: left;}
	.user_c{width:100%;height:22px;line-height: 28px;color:#f08a04;font-size: 0.9rem;overflow: hidden;}
	.shuo{width:100%;height:18px;line-height: 22px;color:#999;font-size: 0.6rem;overflow: hidden;}
	
	.user_c2{width:100%;height:22px;line-height: 28px;color:#666;font-size: 0.9rem;overflow: hidden;}
	.zhong_2{width:2%;float: left;text-align: center;}
	.zhong_2 view{width:1px;height:40px;background-color: #eee;}
	.zhong_3{width:49%;float: left;}
	.advert{width:96%;padding: 8px 2%;background-color: rgb(245, 245, 245);}
	.advert image{width:100%;border-radius: 20px;}
	
	.order{width:100%;}
	.order_1{width:96%;padding: 0px 2%;overflow: hidden;border-bottom: 1px rgb(245, 245, 245) solid;}
	.order_1_1{width:50%;height:40px;line-height: 40px;font-size: 1rem;float: left;color:#333;font-weight: 600;}
	.order_1_2{width:50%;height:40px;float: left;overflow: hidden;}
	.order_1_2 image{width:16px;margin-top:12px;float: right;}
	.order_1_2 text{line-height: 40px;float: right;color:#999;}
	
	.order_2{width:100%;overflow: hidden;padding: 12px 0px;}
	.status{width:33.33%;float: left;position: relative;display: block;}
	.status_1{width:100%;text-align: center;}
	.status_1 image{width:60px;}
	.status_2{width:100%;height:22px;line-height: 22px;color:#666;text-align: center;font-size: 0.9rem;}
	.count{border:1px #f36 solid;border-radius: 15px;padding: 0px 5px;line-height: 15px;position: absolute;top:-5px;font-size: 0.6rem;color:#f36;z-index: 9999;right:16%;background-color: #fff;}
	.fenge{width:100%;height:6px;background-color: rgb(245, 245, 245);}
	
	.tui_goods{width:96%;padding-left: 2%;padding-right: 2%;overflow: hidden;margin-top: 15px;}
	.tui_goods_1{width:50%;float: left;margin-bottom: 10px;}
	.tui_goods_1_1{width:98%;}
	.tui_goods_1_1 image{width:100%;border-radius: 5px;}
	.tui_title{width:100%;height:25px;line-height: 25px;color:#666;overflow:hidden;text-overflow: ellipsis;white-space: nowrap; }
	.tui_price{width:100%;height:25px;line-height: 25px;color:#f36;}
	.tui_goods_1:nth-of-type(even) .tui_goods_1_1{float: right;}
	.tui_price text{font-size: 0.7rem;color:#999;float: right;}
	
	.mingcheng{width:100%;overflow: hidden;margin-top:10px;}
	.mc_1{width:35%;height:22px;line-height: 22px;float: left;color:#666;text-align: right;}
	.mc_2{width:30%;height:22px;line-height: 22px;float: left;color:#666;text-align: center;font-size: 0.9rem;}
	.mc_3{width:35%;height:22px;line-height: 22px;float: left;color:#666;text-align: left;}
	
	.mc_1 view{width:60%;height:1px;background-color: #666;margin-top: 11px;float: right;}
	
	.mc_3 view{width:60%;height:1px;background-color: #666;margin-top: 11px;float: left;}
	.mc_1 text{float: right;margin-left: 5px;}
	.mc_3 text{float: left;margin-right: 5px;}
</style>
